//package com.zf.dtp.web;
//
//import net.zf.dynamic.threadpool.bean.DynamicThreadPoolContext;
//import net.zf.dynamic.threadpool.bean.ThreadPoolConfig;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import java.util.HashMap;
//import java.util.Map;
//import java.util.concurrent.ThreadPoolExecutor;
//
//@RestController
//@RequestMapping("/threadpool")
//public class ThreadPoolController {
//
//    private static final Logger log = LoggerFactory.getLogger(ThreadPoolController.class);
//    @Autowired
//    private ThreadPoolExecutor threadPoolExecutor_1;Th
//
//    @Autowired
//    private ThreadPoolExecutor threadPoolExecutor_2;
//
//
//    @GetMapping("/info")
//    public Map<String, Object> info(){
//        Map<String, Object> infoMap = new HashMap<>();
//
//        Map<String, Object> threadPool1Map = new HashMap<>();
//        threadPool1Map.put("coreSize", threadPoolExecutor_1.getCorePoolSize());
//        threadPool1Map.put("maxSize", threadPoolExecutor_1.getMaximumPoolSize());
//        threadPool1Map.put("activeCount", threadPoolExecutor_1.getActiveCount());
//        threadPool1Map.put("queueSize", threadPoolExecutor_1.getQueue().size());
//
//        infoMap.put("threadPool1", threadPool1Map);
//
//        Map<String, Object> threadPool2Map = new HashMap<>();
//
//        threadPool2Map.put("coreSize", threadPoolExecutor_2.getCorePoolSize());
//        threadPool2Map.put("maxSize", threadPoolExecutor_2.getMaximumPoolSize());
//        threadPool2Map.put("activeCount", threadPoolExecutor_2.getActiveCount());
//        threadPool2Map.put("queueSize", threadPoolExecutor_2.getQueue().size());
//
//        infoMap.put("threadPool2Map", threadPool2Map);
//
//        return infoMap;
//    }
//
//    @RequestMapping("/update")
//    public boolean update(){
//        ThreadPoolConfig threadPoolConfig = new ThreadPoolConfig();
//        threadPoolConfig.setThreadPoolName("threadPoolExecutor_1");
//        threadPoolConfig.setCorePoolSize(1);
//        threadPoolConfig.setMaxPoolSize(2);
//
//        return SpringApplicationCo.updateThreadPoolConfig(threadPoolConfig);
//    }
//
//
//    @RequestMapping("/mock/run")
//    public String run() throws InterruptedException {
//        int i=0;
//        while (i<100){
//            threadPoolExecutor_1.submit(new Runnable() {
//                @Override
//                public void run() {
//                    log.info("threadName: {}", Thread.currentThread().getName());
//                    try {
//                        Thread.sleep(1000);
//                    } catch (InterruptedException e) {
//                        throw new RuntimeException(e);
//                    }
//                }
//            });
//
//            i++;
//
//        }
//
//        return "success";
//    }
//}
//
